package com.xuan.webfinally.controller;


import com.xuan.webfinally.service.ISlopeWeatherDataService;
import com.xuan.webfinally.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 气象监测数据表 前端控制器
 * </p>
 *
 * @author gyuxuan
 * @since 2025-05-18
 */
@RestController
@RequestMapping("/slope-weather-data")
public class SlopeWeatherDataController {
//    @GetMapping("/tqgk")
//    public List<Map<String, Object>> getTQGK() {
//        return List.of(
//                Map.of("icon", "/assets/comm/wdIcon.png", "label", "温度", "value", 5, "unit", "℃"),
//                Map.of("icon", "/assets/comm/kqsdIcon.png", "label", "空气湿度", "value", 60, "unit", "%"),
//                Map.of("icon", "/assets/comm/flIcon.png", "label", "风力", "value", 1, "unit", "级"),
//                Map.of("icon", "/assets/comm/fsIcon.png", "label", "风速", "value", 4, "unit", "km/h")
//        );
//    }
            @Autowired
            private ISlopeWeatherDataService slopeWeatherDataService;
            @GetMapping("/tqgk")
            public Result<Map<String, Object>> getTQGK() {

                if (slopeWeatherDataService.getLatestSlopeInfo().getData()==null)
                {
                    return Result.error("暂无数据");
                }
               return slopeWeatherDataService.getLatestSlopeInfo();


//                return Result.success(List.of(
//                Map.of("icon", "/assets/comm/wdIcon.png", "label", "温度", "value", 5, "unit", "℃"),
//                Map.of("icon", "/assets/comm/kqsdIcon.png", "label", "空气湿度", "value", 60, "unit", "%"),
//                Map.of("icon", "/assets/comm/flIcon.png", "label", "风力", "value", 1, "unit", "级"),
//                Map.of("icon", "/assets/comm/fsIcon.png", "label", "风速", "value", 4, "unit", "km/h")
//         ));
}

}
